package top.dreamcenter.rss.rsssolverweb.util;

import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class RedisHelper {

    private final StringRedisTemplate template;

    public RedisHelper(StringRedisTemplate template) {
        this.template = template;
    }


    public Map<String, String> getHashResults(String key) {
        HashOperations<String, String, String> ops = template.opsForHash();
        return ops.entries(key);
    }
    
    public long delHashResult(String key, String hk) {
        HashOperations<String, String, String> ops = template.opsForHash();
        return ops.delete(key, hk);
    }

    public void addHashResult(String key, String hk, String hv) {
        HashOperations<String, String, String> ops = template.opsForHash();
        ops.put(key, hk, hv);
    }

}
